package com.bo.threadEnd;

/**
 * @Author: gpb
 * @Date: 2024/7/15 22:44
 * @Description:
 */
public class Exception {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            while (true){
                // 获取任务
                // 拿到任务，执行任务
                // 没有任务了，让线程休眠
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    System.out.println("基于打断方式终止线程");
                    e.printStackTrace();
                    return;
                }
            }
        });
        t.start();
        Thread.sleep(500);
        t.interrupt();
    }
}
